
import gnu.io.*;
import java.util.*;
import java.io.InputStream;

public class readserial {
	static Enumeration	      portList;
	static CommPortIdentifier portId;
	static SerialPort		  serialPort;
	public static void main(String[] args) throws Exception {
		String port = "/dev/tty.usbserial-A9007M6s";
		CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(port);
		System.out.println("Found Serial Port");
		serialPort =  (SerialPort) portId.open("Reader", 2000);
		System.out.println("Connected to Serial Port");
		InputStream in = serialPort.getInputStream();
		System.out.println("Got Serial port InputStream");
		serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
		System.out.println("Set Port Params Complete");
		byte[] buffer = new byte[1024];
		int len = -1;
		while ( ( len = in.read(buffer)) > -1 )
		{
			System.out.print(new String(buffer,0,len));
		}
	}
}

